package com.suixun.service.mongodb;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.suixun.dao.mongodb.DeviceCacheDao;
import com.suixun.entity.mongodb.DeviceCache;
import com.suixun.util.db.MongoDBPagination;

@Service("deviceCacheService")
public class DeviceCacheService {

    @Resource(name = "deviceCacheDao")
	private DeviceCacheDao deviceCacheDao;

	public DeviceCache findByid(int id) {
		return deviceCacheDao.findById(id);
	}

	public DeviceCache findOne(Map<String, String> params) {
		return this.deviceCacheDao.findOne(params);
	}
	
	public List<DeviceCache> find(Query query) {
        return this.deviceCacheDao.find(query);
    }
	
	public DeviceCache save(DeviceCache bean) {
		return deviceCacheDao.save(bean);
	}

	public MongoDBPagination<DeviceCache> getPageArticle(int pageNo, int pageSize) {
		return deviceCacheDao.getPageArticle(pageNo, pageSize);
	}

	/**
	 * 暂时只是固定去修改,会有下一篇博客,写高级修改...
	 */
	public void update(String id, Map<String, String> params) {
		this.deviceCacheDao.updateEntity(id, params);
	}
	
	public DeviceCache findAndRemove(Query query) {
        return this.deviceCacheDao.findAndRemove(query);
    }
	
	public void findAllAndRemove(Query query) {
        this.deviceCacheDao.findAllAndRemove(query);
    }
	
	public DeviceCache findAndModify(Query query, Update update) {

        return this.deviceCacheDao.findAndModify(query, update);
    }
}
